package com.jsp.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.jsp.bean.RentcarBean;
import com.jsp.bean.UserBean;
import com.jsp.util.DBUtil;

public class ResultDao {
	
	public  List<RentcarBean> result(RentcarBean rentcar) throws SQLException{
    List <RentcarBean> list = new ArrayList <RentcarBean>();
    Connection con = DBUtil.getConnection();
    String sql = "select * from rentcarinformation where apply_name='"+rentcar.getApply_name()+"'";
    System.out.println(sql);
    PreparedStatement state = con.prepareStatement(sql);
	ResultSet rs = state.executeQuery(); 
    while(rs.next()){
    	rentcar=new RentcarBean();
    	rentcar.setId(rs.getString("id"));
       	rentcar.setApply_name(rs.getString("apply_name"));
       	rentcar.setOpenTime(rs.getString("openTime"));
       	rentcar.setReturnTime(rs.getString("returnTime"));
       	rentcar.setReason(rs.getString("reason"));
       	rentcar.setApply_car(rs.getString("apply_car"));
       	rentcar.setApply_driver(rs.getString("apply_driver"));
       	rentcar.setOpinion(rs.getString("opinion"));
    	list.add(rentcar);
//        rs.getString("id");
//        rs.getString("apply_name");
//        rs.getString("openTime");
//        rs.getString("returnTime");
//        rs.getString("reason");
//        rs.getString("apply_car");
//        rs.getString("apply_driver");
//        rs.getString("opinion")    ;              
//            state.setString(1,rs.getString("id") );  
//            state.setString(2,rs.getString("apply_name") );  
//            state.setString(3,rs.getString("openTime") );  
//            state.setString(4,rs.getString("returnTime") );  
//            state.setString(5,rs.getString("reason") );  
//            state.setString(6,rs.getString("apply_car") );  
//            state.setString(1,rs.getString("apply_driver") );  
//            state.setString(1,rs.getString("opinion") );          
      } 
        state.close();
        con.close();
		return list;   
}
	}
	
